class GameBoy{
  constructor(name,age){
    this.name = name
    this.age = age
    this.taskList = []
    setTimeout(() => {
      this.next()
    }, 0);
  }


  play(ballType) {
    this.taskList.push(()=>{
      console.log(`${this.name} is play ${ballType}`);
    })
    return this;
  }

  sleep(time) {
    this.taskList.push(()=>{
      setTimeout(() => {
        console.log(`i need sellp ${time} ms`);
      }, time);
    })
    return this;
  }

  next() {
    const next = this.taskList.shift();

    next && next();
  }
}